{% extends "submit/submit_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load humanize %}
{% load django_bootstrap5 %}
{% block title %}Add pre-approval{% endblock %}
{% load ietf_filters %}
{% block submit_content %}
    {% origin %}
    <h2 class="mt-3">Add pre-approval</h2>
    <p>
        You can register a pre-approved Internet-Draft name. Then the chair
        approval step of group <code>-00</code> submissions is suspended for that Internet-Draft name
        so a future submission is posted to the data tracker immediately.
    </p>
    <p>
        When the revision <code>-00</code> Internet-Draft is submitted, the pre-approval will not
        be shown anymore as it has fulfilled its purpose (only revision <code>-00</code> submissions are
        subject to approval). If the Internet-Draft never shows up, you can instead
        later cancel the pre-approval to get rid of it.
    </p>
    <h2 class="mt-3">Instructions</h2>
    <p class="alert alert-warning my-3">
        Do not include a version (like <code>-00</code>) and do not include a file extension
        (like <code>.txt</code>) in the name.
    </p>
    {% if user|has_role:"Secretariat" %}
        <p class="alert alert-info my-3">
            Only group submissions are subject to approval and are thus pre-approvable.
        </p>
    {% else %}
        <p>
            As chair
            {% if groups|length > 1 %}of {{ groups|length|apnumber }} groups{% endif %}
            you can pre-approve Internet-Draft names on the form:
        </p>
        <p class="buttonlist">
            {% for g in groups %}
                <button type="button" class="btn btn-primary name-template">
                    draft-ietf-<b>{{ g.acronym }}</b>-<i>something</i>
                </button>
            {% endfor %}
        </p>
    {% endif %}
    <form method="post">
        {% csrf_token %}
        {% bootstrap_form form %}
        <button type="submit" class="btn btn-primary">Save</button>
        <a class="btn btn-secondary float-end"
           href="{% url "ietf.submit.views.approvals" %}#preapprovals">Back</a>
    </form>
{% endblock %}
{% block js %}
    <script>
        $(".name-template").click(function (){
            $("form input[name=name]").text("").focus().val($(this).text().replace("something", ""));
        });
    </script>
{% endblock %}